{{Strip}}{{Extend "layout"}}
{{/*Block "bodyNav"}}
{{Include "filemanager/file.dirnav"}}
{{/Block*/}}
{{Block "title"}}{{"附件管理"|$.T}}{{/Block}}
{{Block "breadcrumb"}}
{{Super}}
<li>{{"附件管理"|$.T}}</li>
<li class="active">{{"文件管理"|$.T}}: {{/* $.Stored.Get "absPath" */}}
    <a href="{{call $.Func.URLPrefix}}">
        <span class="badge badge-primary">{{$.Stored.rootPath}}</span>
    </a>
    {{- range $k,$v := $.Stored.pathLinks -}}
    /<a href="{{$v.V}}">{{$v.K}}</a>
    {{- end -}}
</li>
{{/Block}}

{{Block "head"}}
{{Include "filemanager/file.head"}}
{{/Block}}

{{Block "main"}}
{{- $path := $.Stored.Get "path" -}}
<div class="row">
	<div class="col-md-12">
		<div class="block-flat no-padding">
			<div class="header">
				<div class="btn-group">
                    {{Include "manager/uploaded_file_btn"}}
                    <span class="input-group" style="padding-left:10px">
                        <input type="text" id="query-current-path" name="query" class="form-control typeahead" required="required" value="{{$.Form `query`}}" data-provide="typeahead">
                        <span class="input-group-btn"><button class="btn btn-default" type="button" id="btn-query-current-path"><i class="fa fa-search"></i></button></span>
                    </span>
				</div>
			</div>
			<div class="content">
				<div class="table-responsive">
				<table class="table no-border hover">
					<thead class="no-border">
						<tr>
							<th><strong>{{"名称"|$.T}}</strong></th>
							<th style="width:130px"><strong>{{"修改日期"|$.T}}</strong></th>
							<th style="width:80px"><strong>{{"类型"|$.T}}</strong></th>
							<th style="width:80px"><strong>{{"大小"|$.T}}</strong></th>
							<th style="width:80px"><strong>{{"操作"|$.T}}</strong></th>
						</tr>
					</thead>
					<tbody class="no-border-y" id="tbody-content">
                        {{- if $path -}}
                        <tr>
							<td>
                                <i class="fa fa-folder-o"></i>
                                <a title="{{`点击回到上一级`|$.T}}" href="{{call $.Func.URLPrefix}}?path={{$path}}/.." style="font-size:18px;font-weight:bold" data-toggle="tooltip">..</a>
                            </td>
							<td></td>
							<td></td>
							<td></td>
							<td class="text-center"></td>
						</tr>
                        {{- end -}}
                        {{- range $k,$v := $.Stored.dirs -}}
						<tr item='{{$v.Name}}'>
							<td>
                                {{- if $v.IsDir -}}
                                <i class="fa fa-folder-o"></i>
                                {{- else -}}
                                {{- $fileType := FileTypeByName $v.Name -}}
                                <i class="fa fa-{{FileTypeIcon $fileType}}"></i>
                                {{- if eq $fileType `image` -}}
                                <a class="pull-right" href="{{call $.Func.URLPrefix}}?inline=1&path={{if $path}}{{$path}}/{{end}}{{$v.Name}}" target="_blank"><img src="{{call $.Func.URLPrefix}}?inline=1&path={{if $path}}{{$path}}/{{end}}{{$v.Name}}" style="max-width:100px;max-height:30px;" class="previewable" /></a>
                                {{- end -}}
                                {{- end -}}
                                &nbsp;<a href="{{call $.Func.URLPrefix}}?path={{if $path}}{{$path}}/{{end}}{{$v.Name}}">{{$v.Name}}</a>
                                {{- if $.Stored.canEdit -}}
                                &nbsp;<a href="javascript:;" title="{{`重命名`|$.T}}" data-url="{{call $.Func.URLPrefix}}?do=rename&path={{if $path}}{{$path}}/{{end}}{{$v.Name}}" onclick="fileRename(this,'{{$v.Name}}',{{if $v.IsDir}}true{{else}}false{{end}})" data-toggle="tooltip">
                                <i class="fa fa-pencil"></i>
                                </a>
                                {{- end -}}
                            </td>
							<td>{{$v.ModTime.Format "2006-01-02 15:04:05"}}</td>
							<td>{{if $v.IsDir}}{{"文件夹"|$.T}}{{else}}{{"文件"|$.T}}{{end}}</td>
							<td>{{if $v.IsDir}}-{{else}}{{FormatByte $v.Size 2 true}}{{end}}</td>
							<td>{{- if $.Stored.canDelete -}}
                                <a title="{{`删除`|$.T}}" class="label label-danger" href="{{call $.Func.URLPrefix}}?do=delete&path={{if $path}}{{$path}}/{{end}}{{$v.Name}}" onclick="return confirm('{{$.T `真的要删除“%v”吗？` $v.Name}}');" data-toggle="tooltip">
                                <i class="fa fa-times"></i>
                                </a>
                                {{- end -}}
                                {{- if not $v.IsDir -}}
                                {{- if call $.Func.Editable $v.Name -}}
                                &nbsp;<a title="{{`编辑`|$.T}}" class="label label-success" href="javascript:;" data-url="{{call $.Func.URLPrefix}}?do=edit&path={{if $path}}{{$path}}/{{end}}{{$v.Name}}" onclick="fileEdit(this,'{{$v.Name}}')" data-toggle="tooltip">
                                <i class="fa fa-pencil"></i>
                                </a>
                                {{- end -}}
                                {{- $mediaMime:=call $.Func.Playable $v.Name -}}
                                {{- if $mediaMime -}}
                                &nbsp;<a title="{{`播放`|$.T}}" class="label label-primary" href="javascript:;" playable data-mime="{{$mediaMime}}" data-name="{{$v.Name}}" data-url="{{call $.Func.URLPrefix}}?path={{if $path}}{{$path}}/{{end}}{{$v.Name}}" onclick="filePlay(this)" data-toggle="tooltip">
                                <i class="fa fa-play"></i>
                                </a>
                                {{- end -}}
                                {{- end -}}
                            </td>
						</tr>
                        {{- end -}}
					</tbody>
				</table>		
				</div>
			</div>
		</div>				
	</div>
</div>
 
{{/Block}}

{{Block "footer"}}
{{Include "filemanager/file.script"}}
<script>
function uploadURL(currentPath){
    return '{{call $.Func.URLPrefix}}?do=upload&path='+encodeURIComponent(currentPath);
}
function initDropzone(options) {
    $('#multi-upload-dropzone').dropzone($.extend({},options,{
        url:uploadURL('{{$.Stored.path}}'),
        dictDefaultMessage:'{{"可以把文件拖到这里来进行上传哦"|$.T}}'
    }));
    $('#multi-upload-zip-dropzone').dropzone($.extend({},options,{
        url:uploadURL('{{$.Stored.path}}')+'&pipe=unzip',
        dictDefaultMessage:'{{"可以把文件拖到这里来进行上传哦"|$.T}}<p>{{"仅支持上传zip压缩包。成功解压到当前目录后，该压缩包会被自动删除"|$.T}}</p>',
        acceptedFiles:'application/zip,application/x-zip-compressed'
    }));
}
$(function(){
    App.treeToggle();
});
</script>
<script type="text/javascript" src="{{AssetsURL}}/js/behaviour/page/file.min.js?t={{BuildTime}}"></script>
{{/Block}}
{{/Strip}}